/*

Author   : chaos

FileName : stl_fun-math.cpp

Date     : 17/08/17 17:27:42

*/
#include <iostream>
#include <functional>
#include <algorithm>
#include <vector>
using namespace std;

void print(int i){ cout << i << " "; }

int main(int argc ,char *argv[])
{
    int a[] = {1,4,7,2,9,4,3};
    vector<int> v1(a,a+7), v2 = v1, v3(v1.size());

    cout << "transform element ..." << endl << "v1 : " ;
    for_each(v1.begin() ,v1.end() ,print);
    cout << endl << "v2 : ";
    for_each(v2.begin(),v2.end(),print);
    cout << endl << "v3 (v1 + v2) ;";
    transform(v1.begin() ,v1.end() ,v2.begin() ,v3.begin(),plus<int>());

    for_each(v3.begin() ,v3.end() ,print);
    cout << endl;

    cout << "sort element .." <<  endl << "v3 : " ;
    sort(v3.begin() ,v3.end() ,greater<int>());

    for_each(v3.begin(), v3.end() ,print);
    cout << endl;
    return 0;
}



